package com.work.security;

import jakarta.servlet.FilterChain;
import jakarta.servlet.ServletException;
import jakarta.servlet.http.HttpServletRequest;
import jakarta.servlet.http.HttpServletResponse;
import lombok.extern.slf4j.Slf4j;
import org.springframework.security.core.context.SecurityContextHolder;
import org.springframework.stereotype.Component;
import org.springframework.web.filter.OncePerRequestFilter;

import java.io.IOException;

//拦截token验证
@Slf4j
@Component
public class UserAuthFilter extends OncePerRequestFilter {
    @Override
    protected void doFilterInternal(HttpServletRequest request, HttpServletResponse response, FilterChain filterChain) throws ServletException, IOException {

//        检查token
//        checkToken();
//        验证token
//        validateToken();
//        设置认证上下文
//        SecurityContextHolder.getContext().setAuthentication();
//        认证失败、清除上下文
//        SecurityContextHolder.clearContext();
        filterChain.doFilter(request, response);
    }
}
